import { reactive } from "vue";
import { defineStore } from 'pinia';

export const useProjectStore = defineStore('project', {
    state: () => ({
        projectModel: reactive({
            id: '',
            projectName: '',
            basis: '',
            description: '',
            startTime: null,
            endTime: null,
            managerId: '',
            managerName: '',
            initiatorId: '',
            initiatorName: '',
            status: null,
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
            projectDocuments: [],
            updateProperties: []
        }),
        requirementModel: reactive({
            id: '',
            projectId: '',
            projectName: '',
            status: null,
            mark: '',
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
            requirements: [],
            updateProperties: []
        }),
        scheduleModel: reactive({
            id: '',
            projectId: '',
            projectName: '',
            scheduleName: '',
            status: null,
            progress: null,
            mark: '',
            startTime: null,
            endTime: null,
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
            tasks: [],
            updateProperties: []
        }),
        taskModel: reactive({
            id: '',
            mid: '',
            taskName: '',
            projectId: '',
            pId: '',
            pName: '',
            rId: '',
            rName: '',
            fId:'',
            fTitle:'',
            mark: '',
            startTime: null,
            endTime: null,
            progress: null,
            sort: null,
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
        }),
        taskDoModel: reactive({
            id: '',
            taskId: '',
            progress: null,
            mark: '',
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
            addUserName: ''
        }),
        teamModel: reactive({
            id: '',
            projectId: '',
            projectName: '',
            teamName: '',
            status: null,
            mark: '',
            startTime: null,
            endTime: null,
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
            members: [],
            updateProperties: []
        }),
        teamMemberModel: reactive({
            id: '',
            mid: '',
            projectId: '',
            userId: '',
            userName: '',
            mark: '',
            entryTime: null,
            exitTime: null,
            addTime: null,
            addUserId: '',
            editTime: null,
            editUserId: '',
        }),
        changeModel: reactive({
            id: '',
            projectId: '',
            projectName: '',
            changeName: '',
            changeType: null,
            reason: '',
            status: null,
            createUserId: '',
            createUserName: '',
            createTime: null,
            changeInfos:[],
            updateProperties: []
        }),
        projectSettingModel: reactive({
            id: '',
            skey: null,
            svalue: '',
            stype: '',
        }),
        requirementType: [
            {
                value: 1,
                label: '功能',
            },
            {
                value: 2,
                label: '接口',
            },
            {
                value: 3,
                label: '列表',
            },
            {
                value: 4,
                label: '按钮',
            },
        ],
    }),
    actions: {
        resetProjectModel() {
            this.projectModel = {
                id: '',
                projectName: '',
                basis: '',
                description: '',
                startTime: null,
                endTime: null,
                managerId: '',
                managerName: '',
                initiatorId: '',
                initiatorName: '',
                status: null,
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
                projectDocuments: [],
                updateProperties: []
            };
        },
        resetProjectSettingModel() {
            this.projectSettingModel = {
                id: '',
                skey: null,
                svalue: '',
                stype: '',
            };
        },
        resetRequirementModel() {
            this.requirementModel = {
                id: '',
                projectId: '',
                projectName: '',
                status: null,
                mark: '',
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
                requirements: [],
                updateProperties: []
            }
        },
        resetScheduleModel() {
            this.scheduleModel = {
                id: '',
                projectId: '',
                projectName: '',
                scheduleName: '',
                status: null,
                progress: null,
                mark: '',
                startTime: null,
                endTime: null,
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
                tasks: [],
                updateProperties: []
            }
        },
        resetTaskModel() {
            this.taskModel = {
                id: '',
                mid: '',
                taskName: '',
                projectId: '',
                pId: '',
                pName: '',
                rId: '',
                rName: '',
                mark: '',
                startTime: null,
                endTime: null,
                progress: null,
                sort: null,
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
            }
        },
        resetTaskDoModel() {
            this.taskDoModel = {
                id: '',
                taskId: '',
                progress: null,
                mark: '',
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
                addUserName: ''
            }
        },
        resetTeamModel() {
            this.teamModel = {
                id: '',
                projectId: '',
                projectName: '',
                teamName: '',
                status: null,
                mark: '',
                startTime: null,
                endTime: null,
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
                members: [],
                updateProperties: []
            }
        },
        resetTeamMemberModel() {
            this.teamMemberModel = {
                id: '',
                mid: '',
                projectId: '',
                userId: '',
                userName: '',
                mark: '',
                entryTime: null,
                exitTime: null,
                addTime: null,
                addUserId: '',
                editTime: null,
                editUserId: '',
            }
        },
        resetChangeModel() {
            this.changeModel = {
                id: '',
                projectId: '',
                projectName: '',
                changeName: '',
                changeType: null,
                reason: '',
                status: null,
                createUserId: '',
                createUserName: '',
                createTime: null,
                changeInfos:[],
                updateProperties: []
            }
        },
    },
});